**************************************************
**************************************************
******* Replication Data ISQ-2022-01-0022 ********
**************************************************
**************************************************

* All output produced in Stata 17


/* 
ssc install combomarginsplot
ssc install spost13_ado
ssc install mgen
ssc install catplot
ssc install rangestat
ssc install estout
ssc install grc1leg2
ssc install feologit  // Package by Baetschmann et al., download may not work for some versions: search feologit
*/


clear all
use PTA_level_analysis.dta

log using diffusion_hub_updated.log, replace

**************************************
********* PTA-LEVEL ANALYSIS *********
**************************************

*** TABLE 2 - main results

feologit dv_cr_index dispute_experienceshare bc_mission_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta, group(year)

feologit dv_cr_index  pta_dispute_asymmetry   bc_mission_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta, group(year)

feologit dv_cr_index dispute_experienceshare   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

feologit dv_cr_index pta_dispute_asymmetry   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

feologit dv_cr_index dispute_experienceshare pta_dispute_asymmetry bc_mission_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

xtreg  dv_cr_pca dispute_experienceshare bc_mission_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  dv_cr_pca  bc_mission_diff pta_dispute_asymmetry    market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  dv_cr_pca dispute_experienceshare bc_mission_diff pta_dispute_asymmetry    market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust


** Figure 6

ologit dv_cr_index dispute_experienceshare i.year  bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, vce(cluster year)

sort dispute_experienceshare
 quietly by dispute_experienceshare:  gen ex_share = cond(_N==1,0,_n)
 gen ex_histo=.
 replace ex_histo=dispute_experienceshare if ex_share==0 | ex_share==1


margins, dydx(dispute_experienceshare)
margins, at(dispute_experienceshare = (0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1))

mgen, at(dispute_experienceshare = (0(0.1)1)) expression(predict(outcome(0))+predict(outcome(1))+predict(outcome(2))+predict(outcome(3))+predict(outcome(4))) saving(file_asy_neg, replace)

drop _margin _ll _ul _dispute_experienceshare

mgen, at(dispute_experienceshare = (0(0.1)1)) expression(predict(outcome(5))+predict(outcome(6))+predict(outcome(7)))  saving(file_asy_pos, replace)

combomarginsplot file_asy_neg file_asy_pos , labels("Less than WTO DSU" "More than/Equal WTO DSU")  file1opts(pstyle(p1)) file2opts(pstyle(p2))  lplot1(mfcolor(white)) ytitle("Predicted Probability")  ///
xtitle("Share of Parties with {bf:Dispute Experience}")  recast(line) recastci(rarea) plot1opt(color(navy%80)) ci1opt(color(navy%20)) plot2opt(color(cranberry%80)) ci2opt(color(cranberry%20)) graphregion(color(white)) title("") addplot(hist ex_histo, blcolor(black) fcolor(black) discrete yaxis(2) yscale(alt lstyle(none)  lcolor( ) axis(2)) ylabel(0 " " 20000 " " 40000 " " 60000 " ", labcolor() axis(2) tlcolor() tlwidth(0) labsize(small) tl(0)) ytitle(" ", axis(2)) legend(order(3 "Fewer CR than WTO DSU" 4 "More CR than or equal to WTO DSU")) legend(size(vsmall)))
graph save fig6_left, replace
graph export "fig6_left", as(eps) replace


ologit dv_cr_index pta_dispute_asymmetry bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta i.year if year > 1994, vce(cluster year)

sort pta_dispute_asymmetry
 quietly by pta_dispute_asymmetry:  gen dupdahist = cond(_N==1,0,_n)
 gen dahisto=.
 replace dahisto=pta_dispute_asymmetry if dupdahist==0 | dupdahist==1
 
margins, dydx(pta_dispute_asymmetry)
margins, at(pta_dispute_asymmetry = (0 0.1 0.2 0.3 0.4 0.5))

drop _margin _ul  _ll

mgen, at(pta_dispute_asymmetry = (0(0.1)0.5)) expression(predict(outcome(0))+predict(outcome(1))+predict(outcome(2))+predict(outcome(3))+predict(outcome(4)))  saving(margdispute_neg4, replace)

drop _margin _ul _pta_dispute_asymmetry _ll

mgen, at(pta_dispute_asymmetry = (0(0.1)0.5)) expression(predict(outcome(5))+predict(outcome(6))+predict(outcome(7)))  saving(margdispute_pos4, replace)

combomarginsplot margdispute_neg4 margdispute_pos4 , labels("Less than WTO DSU" "More than/Equal WTO DSU")  file1opts(pstyle(p1)) file2opts(pstyle(p2))  lplot1(mfcolor(white)) ///
xtitle("{bf:Trade Dispute Asymmetry}") ytitle("Predicted Probability")  recast(line) recastci(rarea) plot1opt(color(navy%80)) ci1opt(color(navy%20)) plot2opt(color(cranberry%80)) ci2opt(color(cranberry%20)) graphregion(color(white)) title("") addplot(hist dahisto, blcolor(black) fcolor(black) discrete yaxis(2) yscale(alt lstyle(none)  lcolor( ) axis(2)) ylabel(0 " " 20000 " " 40000 " " 60000 " ", labcolor() axis(2) tlcolor() tlwidth(0) labsize(small) tl(0)) ytitle(" ", axis(2)) legend(order(3 "Less than WTO DSU" 4 "More than/Equal WTO DSU")))
graph save fig6_right, replace
graph export "fig6_right", as(eps)  replace

grc1leg2 fig6_left.gph fig6_right.gph , col(2) ycommon iscale(.6) ysize(1) xsize(1.5) graphregion(margin(zero)) graphregion(color(white))
graph save fig6, replace
graph export "fig6.eps", as(eps) replace


*** Table 3 - Component and time horizon models 

xtreg  dv_cr_pca  dispute_10experienceshare   bc_gdp_diff   market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta  if year>1994, fe robust

xtreg  dv_cr_pca    pta_dispute10_asymmetry bc_gdp_diff   market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta  if year>1994, fe robust

xtreg  dv_cr_pca  dispute_10experienceshare pta_dispute10_asymmetry  bc_gdp_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta  if year>1994, fe robust

clogit  dv_comp_forum  dispute_experienceshare  bc_mission_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties  dv_cr_previouspta if year>1994, group(year) robust

clogit  dv_comp_forum  dispute_experienceshare pta_dispute_asymmetry  bc_mission_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties  dv_cr_previouspta if year>1994, group(year) robust

xtreg  pca_noforum  dispute_experienceshare bc_gdp_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  pca_noforum  dispute_experienceshare pta_dispute_asymmetry bc_gdp_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust


******************************************
* ROBUSTNESS CHECKS - PTA level analysis *
******************************************

** Table 5 **

feologit dv_cr_index dispute_experienceshare bc_mission_diff bc_mission_min market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta, group(year)

feologit dv_cr_index  pta_dispute_asymmetry   bc_mission_diff  bc_mission_min market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta, group(year)

feologit dv_cr_index dispute_experienceshare   bc_mission_diff bc_mission_min market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

feologit dv_cr_index pta_dispute_asymmetry   bc_mission_diff bc_mission_min market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

feologit dv_cr_index dispute_experienceshare pta_dispute_asymmetry bc_mission_diff bc_mission_min market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

xtreg  dv_cr_pca dispute_experienceshare bc_mission_diff   bc_mission_min  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  dv_cr_pca  bc_mission_diff pta_dispute_asymmetry  bc_mission_min  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  dv_cr_pca dispute_experienceshare bc_mission_diff bc_mission_min pta_dispute_asymmetry    market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

** Table 6 **

xtreg  dv_cr_pca  dispute_10experienceshare   bc_gdp_diff  bc_gdp_min market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta  if year>1994, fe robust

xtreg  dv_cr_pca    pta_dispute10_asymmetry bc_gdp_diff bc_gdp_min  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta  if year>1994, fe robust

xtreg  dv_cr_pca  dispute_10experienceshare pta_dispute10_asymmetry  bc_gdp_diff bc_gdp_min market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta  if year>1994, fe robust

clogit  dv_comp_forum  dispute_experienceshare  bc_mission_diff   bc_mission_min  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties  dv_cr_previouspta if year>1994, group(year) robust

clogit  dv_comp_forum  dispute_experienceshare pta_dispute_asymmetry  bc_mission_diff   bc_mission_min  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties  dv_cr_previouspta if year>1994, group(year) robust

xtreg  pca_noforum  dispute_experienceshare bc_gdp_diff bc_gdp_min market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  pca_noforum  dispute_experienceshare pta_dispute_asymmetry bc_gdp_diff bc_gdp_min   market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

** Table 7 **

xtreg  dv_cr_index dispute_experienceshare bc_mission_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta, fe robust

xtreg  dv_cr_index pta_dispute_asymmetry bc_mission_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta, fe robust

ologit dv_cr_index dispute_experienceshare bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta i.year if year > 1994, vce(cluster year)

ologit dv_cr_index pta_dispute_asymmetry bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta i.year if year > 1994, vce(cluster year)

ologit dv_cr_index dispute_experienceshare pta_dispute_asymmetry bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta i.year if year > 1994, vce(cluster year)

xtreg  dv_cr_index dispute_experienceshare bc_mission_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  dv_cr_index  bc_mission_diff pta_dispute_asymmetry    market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  dv_cr_index dispute_experienceshare bc_mission_diff pta_dispute_asymmetry    market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

* Figure 10 (based on Table 7)

xtreg  dv_cr_index  bc_mission_diff pta_dispute_asymmetry    market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

sort pta_dispute_asymmetry
quietly by pta_dispute_asymmetry:  gen newdahist = cond(_N==1,0,_n)
gen dnewhisto=.
replace dnewhisto=pta_dispute_asymmetry if newdahist==0 | newdahist==1
 
margins, at(pta_dispute_asymmetry = (0 0.1 0.2 0.3 0.4 0.5)) saving(da_margins, replace)

combomarginsplot da_margins, labels("Fewer Than WTO DSU" "More Than WTO DSU")  file1opts(pstyle(p1))   plot1opt(lcolor(navy))   ci1opt(color(navy%20))  lplot1(mfcolor(white)) recast(line) recastci(rarea)  xtitle(Multilateral Trade Dispute Asymmetry) graphregion(color(white)) ytitle(Complainant Rights) title("") addplot(hist dnewhisto, blcolor(black) fcolor(black) discrete yaxis(2) yscale(alt lstyle(none)  lcolor( ) axis(2)) ylabel(0 " " 20000 " " 40000 " " 60000 " ", labcolor() axis(2) tlcolor() tlwidth(0) labsize(small) tl(0)) ytitle(" ", axis(2)) legend(off))
graph save fig10_right, replace


xtreg  dv_cr_index  dispute_experienceshare bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index number_parties dv_cr_previouspta if year>1994, fe robust

sort dispute_experienceshare
quietly by dispute_experienceshare:  gen dupdexshare = cond(_N==1,0,_n)
gen exshisto=.
replace exshisto=dispute_experienceshare if dupdexshare==0 | dupdexshare==1

margins, at(dispute_experienceshare = (0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1)) saving(exs_margins, replace)

combomarginsplot exs_margins, labels("Fewer Than WTO DSU" "More Than WTO DSU")  file1opts(pstyle(p1))   plot1opt(lcolor(navy))   ci1opt(color(navy%20))  lplot1(mfcolor(white)) recast(line) recastci(rarea)  xtitle(Share of PTA Parties with Previous Experience in Multilateral Disputes) graphregion(color(white)) ytitle(Complainant Rights) title("") addplot(hist exshisto, blcolor(black) fcolor(black) discrete yaxis(2) yscale(alt lstyle(none)  lcolor( ) axis(2)) ylabel(0 " " 20000 " " 40000 " " 60000 " ", labcolor() axis(2) tlcolor() tlwidth(0) labsize(small) tl(0)) ytitle(" ", axis(2)) legend(off))
graph save fig_10left, replace


gr combine fig_10left.gph fig10_right.gph , col(2) ycommon iscale(.70) ysize(8) xsiz(16) graphregion(margin(zero))
graph save fig10, replace
graph export "fig10.eps", as(eps) replace

** Table 8 **

xtreg  dv_cr_pca dispute_experienceshare    bc_gdp_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  dv_cr_pca dispute_experienceshare pta_dispute_asymmetry   bc_gdp_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

feologit dv_cr_index dispute_experienceshare pta_dispute_asymmetry bc_gdp_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

xtreg  dv_weight_pca dispute_experienceshare    bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_weight_previouspta if year>1994, fe robust

xtreg  dv_weight_pca dispute_experienceshare pta_dispute_asymmetry   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_weight_previouspta if year>1994, fe robust

feologit dv_weight dispute_experienceshare pta_dispute_asymmetry bc_mission_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_weight_previouspta if year > 1994, group(year)

xtreg  dv_weight_pca dispute_experienceshare    bc_gdp_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_weight_previouspta if year>1994, fe robust

xtreg  dv_weight_pca dispute_experienceshare pta_dispute_asymmetry   bc_gdp_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_weight_previouspta if year>1994, fe robust

feologit dv_weight dispute_experienceshare pta_dispute_asymmetry bc_gdp_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_weight_previouspta if year > 1994, group(year)

** Table 9 **

gen d_ex_dummy=0
replace d_ex_dummy=1 if dispute_experienceshare==1 & dispute_experienceshare!=.

xtreg  dv_cr_pca d_ex_dummy    bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

feologit dv_cr_index d_ex_dummy  bc_mission_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

xtreg  dv_cr_pca d_ex_dummy pta_dispute_asymmetry   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

feologit dv_cr_index d_ex_dummy pta_dispute_asymmetry bc_mission_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

xtreg  dv_cr_pca dispute_experienceshare pta_disputeasymmetrycategorical   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

feologit dv_cr_index dispute_experienceshare pta_disputeasymmetrycategorical bc_mission_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

xtreg  dv_cr_pca d_ex_dummy pta_disputeasymmetrycategorical   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

feologit dv_cr_index d_ex_dummy pta_disputeasymmetrycategorical bc_mission_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

** Table 10 **


xtreg  dv_cr_pca  dispute_10experienceshare   bc_mission_diff   market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta  if year>1994, fe robust

xtreg  dv_cr_pca    pta_dispute10_asymmetry bc_mission_diff   market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta  if year>1994, fe robust

xtreg  dv_cr_pca  dispute_10experienceshare pta_dispute10_asymmetry  bc_mission_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta  if year>1994, fe robust


clogit  dv_comp_forum  dispute_experienceshare  bc_mission_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties  dv_cr_previouspta if year>1994, group(year) robust

clogit  dv_comp_forum  dispute_experienceshare pta_dispute_asymmetry  bc_mission_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties  dv_cr_previouspta if year>1994, group(year) robust

clogit  dv_comp_forum  dispute_experienceshare  bc_gdp_diff    market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties  dv_cr_previouspta if year>1994, group(year) robust

clogit  dv_comp_forum  dispute_experienceshare pta_dispute_asymmetry  bc_gdp_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties  dv_cr_previouspta if year>1994, group(year) robust

xtreg  pca_noforum  dispute_experienceshare bc_gdp_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  pca_noforum  dispute_experienceshare pta_dispute_asymmetry bc_gdp_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  pca_noforum  dispute_experienceshare bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

xtreg  pca_noforum  dispute_experienceshare pta_dispute_asymmetry bc_mission_diff     market_access_diff   retaliatory_capacity_diff  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

** Table 11 **

feologit dv_cr_index dispute_experienceshare bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy     number_parties dv_cr_previouspta, group(year)

feologit dv_cr_index  pta_dispute_asymmetry   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy     number_parties dv_cr_previouspta, group(year)

feologit dv_cr_index dispute_experienceshare pta_dispute_asymmetry   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy     number_parties dv_cr_previouspta, group(year)

xtreg  dv_cr_pca dispute_experienceshare pta_dispute_asymmetry   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy     number_parties dv_cr_previouspta, fe robust

feologit dv_cr_index dispute_experienceshare   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy     number_parties dv_cr_previouspta if year > 1994, group(year)

feologit dv_cr_index pta_dispute_asymmetry   bc_mission_diff market_access_diff   retaliatory_capacity_diff  wto_share all_democracy     number_parties dv_cr_previouspta if year > 1994, group(year)

feologit dv_cr_index dispute_experienceshare pta_dispute_asymmetry bc_mission_diff  market_access_diff   retaliatory_capacity_diff  wto_share all_democracy     number_parties dv_cr_previouspta if year > 1994, group(year)

xtreg  dv_cr_pca dispute_experienceshare bc_mission_diff pta_dispute_asymmetry    market_access_diff   retaliatory_capacity_diff  wto_share all_democracy     number_parties dv_cr_previouspta if year>1994, fe robust

** Table 12 **

ologit dv_cr_index   dispute_experienceshare bc_mission_diff market_access_diff  retaliatory_capacity_diff  wto_all all_democracy   pta_depth_index  number_parties dv_cr_previouspta i.year##i.year#i.year if year>1994, robust

ologit dv_cr_index pta_dispute_asymmetry   bc_mission_diff market_access_diff  retaliatory_capacity_diff  wto_all all_democracy   pta_depth_index  number_parties dv_cr_previouspta i.year##i.year#i.year if year>1994, robust

xtreg dv_cr_pca   dispute_experienceshare bc_mission_diff market_access_diff  retaliatory_capacity_diff  wto_all all_democracy   pta_depth_index  number_parties dv_cr_previouspta i.year##i.year#i.year if year>1994, robust

xtreg dv_cr_pca  pta_dispute_asymmetry   bc_mission_diff market_access_diff  retaliatory_capacity_diff  wto_all all_democracy   pta_depth_index  number_parties dv_cr_previouspta i.year##i.year#i.year if year>1994, robust

xtreg dv_cr_pca  pta_dispute_asymmetry  dispute_experienceshare bc_mission_diff market_access_diff  retaliatory_capacity_diff  wto_all all_democracy   pta_depth_index  number_parties dv_cr_previouspta i.year##i.year#i.year if year>1994, robust

** Table 13 **

xtreg  dv_cr_pca dispute_experienceshare    bc_mission_diff market_access_diff   tradevolume  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

feologit dv_cr_index dispute_experienceshare  bc_mission_diff  market_access_diff   tradevolume  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

xtreg  dv_cr_pca  pta_dispute_asymmetry   bc_mission_diff market_access_diff   tradevolume  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

feologit dv_cr_index  pta_dispute_asymmetry bc_mission_diff  market_access_diff   tradevolume  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)

xtreg  dv_cr_pca dispute_experienceshare pta_dispute_asymmetry   bc_mission_diff market_access_diff   tradevolume  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year>1994, fe robust

feologit dv_cr_index dispute_experienceshare pta_dispute_asymmetry bc_mission_diff  market_access_diff   tradevolume  wto_share all_democracy   pta_depth_index  number_parties dv_cr_previouspta if year > 1994, group(year)


*****************************
****** MONADIC ANALYSIS *****
*****************************

clear all
use monadic_level_analysis.dta


* Figure 11
esplot dv_cr_index_distance eventtime, period(5) ytitle("Deviation from WTO Complainant Rights") xtitle("Years before/after first Dispute") graphregion(color(white))
graph save fig11, replace
graph export "fig11.eps", as(eps) replace

* Figure 12
esplot dv_cr_index_distance eventtime_third, period(5) ytitle("Deviation from WTO Complainant Rights") xtitle("Years before/after first Dispute") graphregion(color(white))
graph save fig12, replace
graph export "fig12.eps", as(eps) replace

* Figure 13
hist year if switch==1, xtitle("Year") ytitle("Density (First WTO Dispute)") width(1) graphregion(color(white))
graph save fig13, replace
graph export "fig13.eps", as(eps) replace


*** Table 4 - monadic 2FE models ***

* Models D1-D6

reghdfe  dv_cr_index_distance  treatment, absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment  wto_membership EU_membership US_membership , absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment c.year##ccodeN wto_membership EU_membership US_membership,  absorb(ccodeN year) vce(cluster ccodeN)

summarize bc_at_switch if e(sample) & bc_at_switch!=0, d
gen bc_standard=bc_at_switch-8.251341  // standardise on median of bureaucratic capacity

reghdfe  dv_cr_index_distance treatment_third, absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance treatment_third wto_membership EU_membership US_membership , absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance treatment_third c.year##ccodeN wto_membership EU_membership US_membership , absorb(ccodeN year) vce(cluster ccodeN)

summarize bc_at_switch_third bc if e(sample) & treatment_third==1,d
gen bc_third_standard= bc_at_switch_third-8.509349 // standardise on median of bureaucratic capacity

* Models I1-I3 + Figure 8 + I4-I6

summarize bc_at_switch
global MyMin = r(min)
global MyMax = r(max)
global Grid = ($MyMax-$MyMin)/100

reghdfe  dv_cr_index treatment##c.bc_standard, absorb(ccodeN year) vce(cluster ccodeN)

frame create orsCI bc_standard or orlb orub
lincom 0*_b[1.treatment#c.bc_standard]+1*_b[1.treatment]
forvalues a = -2(.1)4 {
    lincom `a'*_b[1.treatment#c.bc_standard]+1*_b[1.treatment]
    frame post orsCI (`a') (`r(estimate)') (`r(lb)') (`r(ub)')
}

frame change orsCI
isid bc_standard, sort
format or %3.2f
format orlb %3.2f
format orub %3.2f
list, noobs clean

graph twoway  (rarea orub orlb bc_standard, color(gs10%30)) (line or bc_standard , sort lcolor(gs90) yline(0, lcolor(red)))  (line  orub bc_standard, lcolor(gs6) ) (line orlb  bc_standard, lcolor(gs6) graphregion(color(white)) ytitle(Post-Dispute Effect) xtitle(Bureaucratic Capacity at Time of First WTO Dispute) legend(off))
graph save fig8, replace
graph export "fig8.eps", as(eps) replace 

frames change default

reghdfe  dv_cr_index_distance  treatment##c.bc_standard wto_membership EU_membership US_membership , absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment##c.bc_standard c.year##ccodeN  EU_membership US_membership wto_membership,  absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance treatment_third##c.bc_third_standard, absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance treatment_third##c.bc_third_standard wto_membership EU_membership US_membership , absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance treatment_third##c.bc_third_standard c.year##ccodeN wto_membership EU_membership US_membership , absorb(ccodeN year) vce(cluster ccodeN)


*******************************************
******* Monadic robustness checks *********
*******************************************

* Table 15 

reghdfe  dv_cr_index_distance  treatment bc, absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment  wto_membership EU_membership US_membership bc , absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment c.year##ccodeN wto_membership EU_membership US_membership bc,  absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance treatment##c.bc_standard bc, absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment##c.bc_standard wto_membership EU_membership US_membership bc, absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment##c.bc_standard c.year##ccodeN  EU_membership US_membership wto_membership bc,  absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment_third bc, absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment_third  wto_membership EU_membership US_membership bc , absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment_third c.year##ccodeN wto_membership EU_membership US_membership bc,  absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance treatment_third##c.bc_third_standard bc, absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment_third##c.bc_third_standard wto_membership EU_membership US_membership bc, absorb(ccodeN year) vce(cluster ccodeN)

reghdfe  dv_cr_index_distance  treatment_third##c.bc_third_standard c.year##ccodeN  EU_membership US_membership wto_membership bc,  absorb(ccodeN year) vce(cluster ccodeN)



*************************************************************
****** CONSTRUCTION OF THE DV & DESCRIPTIVE FIGURES *********
*************************************************************


clear all 
use DESTA_DS_1.3.dta

*** Generate Complainant Rights Index ***

gen dv_comp_dsm=0
replace dv_comp_dsm=1 if ds_prov==1

gen dv_comp_arbi=0
replace dv_comp_arbi=1 if ds_del_arb==1

gen dv_comp_binding=0
replace dv_comp_binding=1 if (ds_binding_prov==1 & ds_binding_exp_yes==1)

gen dv_comp_sanctions=0
replace dv_comp_sanctions=1 if ds_sanc_prov==1

gen dv_comp_forum=0
replace dv_comp_forum=1 if ds_forum==1

gen dv_comp_retaliation=0
replace dv_comp_retaliation=1 if (ds_sanc_compl==1 & ds_sanc_tp!=1 & ds_sanc_dp!=1)

gen dv_comp_sector=0
replace dv_comp_sector=1 if ds_sanc_cross==1

gen dv_comp_monetary=0
replace dv_comp_monetary=1 if ds_sanc_money==1


gen dv_cr_index= dv_comp_dsm + dv_comp_arbi + dv_comp_binding + dv_comp_sanctions + dv_comp_forum + dv_comp_retaliation + dv_comp_sector + dv_comp_monetary


* PCA 

pca dv_comp_dsm dv_comp_arbi dv_comp_binding dv_comp_sanctions dv_comp_forum  dv_comp_retaliation dv_comp_sector dv_comp_monetary
estat loadings
predict dv_cr_pca pca_ext2, score 

estat kmo // Kaiser-Meyer-Olkin Measure of 0.7048

alpha  dv_comp_dsm dv_comp_arbi dv_comp_binding dv_comp_sanctions dv_comp_forum  dv_comp_retaliation dv_comp_sector dv_comp_monetary, std item // Crohnbach's Alpha Reliability check 


* Table 15: Component Correlation

correlate  dv_comp_dsm dv_comp_arbi dv_comp_binding dv_comp_sanctions dv_comp_forum  dv_comp_retaliation dv_comp_sector dv_comp_monetary

eststo: estpost correlate dv_comp_dsm dv_comp_arbi dv_comp_binding dv_comp_sanctions dv_comp_forum  dv_comp_retaliation dv_comp_sector dv_comp_monetary, matrix listwise
esttab, unstack not noobs compress nostar tex


summarize  dv_comp_dsm dv_comp_arbi dv_comp_binding dv_comp_sanctions dv_comp_forum  dv_comp_retaliation dv_comp_sector dv_comp_monetary


* Weighted Index (for robustness checks) 

gen dsm3=.
replace dsm3=0 if ds_prov==0 
replace dsm3=1 if ds_del_con==0 & ds_del_med==0 & ds_del_arb==0 & ds_prov==1 & ds_del_sb==0 
replace dsm3=2 if ds_prov==1 & ds_del_con==1 & ds_del_med==0 & ds_del_arb==0 & ds_del_sb==0
replace dsm3=3 if ds_prov==1 & ds_del_med==1 & ds_del_arb==0 & ds_del_sb==0
replace dsm3=4 if ds_prov==1 & ds_del_arb==1 & ds_del_sb==0
replace dsm3=5 if ds_del_sb==1

gen binding3=.
replace binding3=0 if ds_binding_prov==1 & ds_binding_exp_no==1
replace binding3=0 if ds_binding_prov==0 
replace binding3=1 if ds_binding_prov==1 & ds_binding_exp_yes==1


gen forum3=.
replace forum3=0 if ds_forum==0
replace forum3=1 if ds_forum==1 & ds_forum_restrict==1
replace forum3=2 if ds_forum==1 & ds_forum_restrict==0

gen sanctions3=.
replace sanctions3=1 if ds_sanc_prov==1
replace sanctions3=0 if ds_sanc_prov==0 

gen retaliation3=.
replace retaliation3=0 if ds_sanc_dp==1 & ds_sanc_tp==0
replace retaliation3=1 if (ds_sanc_dp!=1 & ds_sanc_tp==1) | (ds_sanc_dp==1 & ds_sanc_tp==1) | (ds_sanc_compl==1 & ds_sanc_tp==1)
replace retaliation3=2 if (ds_sanc_compl==1 & ds_sanc_tp!=1)
replace retaliation3=0 if retaliation3==.

gen sanc_type3=.
replace sanc_type3=0 if  ds_sanc_cross==0
replace sanc_type3=1 if sanc_type3==.

gen monetary3=.
replace monetary3=1 if ds_sanc_money==1
replace monetary3=0 if monetary3==.

gen dv_weight=.
replace dv_weight= dsm3 + forum3 + binding3 + sanctions3 + retaliation3 + sanc_type3 + monetary3

pca dsm3 forum3 binding3  sanctions3 retaliation3 sanc_type3 monetary3 
estat loadings
predict pca_weight pca_weight2, score 


** Figure 14 **

destring year, replace
label variable dv_cr_index "Complainant Rights Index"

catplot dv_cr_index if year>1978,  bar(1, bcolor(edkblue)) recast(bar) ///
title(" ") ///
ytitle("Number of PTAs", height(4)) ///
note("{bf:Note: Larger values indicate a higher level of complainant rights. GATT=1; WTO=5.}") ///
graphregion(color(white))
graph save fig14, replace
graph export "fig14.eps", as(eps) replace 


* Figure 3 *

sort year
rangestat mean3 = dv_cr_index, interval(year -3 0)

twoway  (scatter dv_cr_index year, color(edkblue)) (function y =  1  , range(1947  1995) lcolor(red)) (function y =  5  , range(1995  2020) lcolor(red)) (line mean3 year, color(eltblue) lwidth(0.5)),  ///
title(" ") ///
ytitle("Complainant Rights", height(6)) ///
xtitle("Year") ///
yscale(range(-0 8)) ///
ylab(-0(2)8) ///
xline(1979, lcolor(gs10)) ///
xline(1995, lcolor(gs10)) ///
legend(order(1 4) label(1 "PTAs") label(4 "3-Year Moving Average")) ///
note("{bf:Note:} The red horizontal lines indicate the complainant rights level of the GATT (1947-1994) and WTO (1995-2020)." "Vertical Lines indicate the GATT Tokyo Round (1979) and creation of the WTO (1995).", size(vsmall)) ///
graphregion(color(white))
graph save fig3, replace
graph export "fig3.eps", as(eps) replace 

* Figure 9 *

clear all 
use fig9_data.dta

graph bar cd_only third_p none, over(var7, sort(order) relabel(1 "Full Period" 2 "WTO-era" 3 "Full Period" 4 "WTO-era")) bar(1, color(navy)) bar(2, color(emidblue)) bar(3, color(eltblue)) legend( label(1 "Complainant/Defendant") label(2 "3rd Party Only")  label(3 "No Dispute Experience") ) legend(region(lstyle(none)) nobox) graphregion(color(white)) ytitle(Complainant Rights) title("") b1title(                    PTA                                           Monadic)
graph save figure9, replace
graph export "fig9.eps", as(eps) replace


* Figure 7 *

clear all
use fig7_data.dta

twoway (bar dispute_participation year, yaxis(1) yscale(range(0) axis(1)) bcolor(edkblue) clcolor(edkblue) barw(0.85)) ///
  (rbar dispute_participation stack_variable year, bcolor(ebg) clcolor(ebg) barw(0.85)) ///
  (line disputes_total year, sort yaxis(2) yscale(range(0(200)800) axis(2))  ylab(0(200)880, axis(2)) mcolor(orange) clcolor(orange) lwidth(0.5)) ///
(line euandus_dispute year, sort yaxis(2) mcolor(maroon) clcolor(maroon) lwidth(0.5)) ///
(line lowincome_dispute year, sort yaxis(2) mcolor(dkgreen) clcolor(dkgreen) lwidth(0.5)), ///
ytitle("Cumulative Number of States", height(6)) ///
xscale (range(1945(20)2017)) ///
xlab(1945(10)2017) ///
ytitle("Cumulative Number of Disputes", height(7) axis(2)) ///
xtitle(" ") ///
title("") ///
legend(label(2 "Third Party Only" ) label(3 "Total Number of Disputes") label(1 "Complainant/Defendant") label(4 "Disputes involving US/EU") label(5 "Disputes involving Low-Income States") size(vsmall)) ///
legend(order(1 2 3 4 5)) ///
legend(region(lstyle(none))) ///
graphregion(color(white))
graph save fig7, replace
graph export "fig7.eps", as(eps) replace

* Figure 1 *

clear all
use fig1_data.dta

twoway (bar cumstates year, yaxis(1) yscale(range(0) axis(1)) bcolor(ebg) clcolor(ebg) barw(0.85)) ///
(line cumtreaties year, sort yaxis(2) yscale(range(0(200)900) axis(2))  ylab(0(200)884, axis(2)) xlab(1945(10)2017) mcolor(edkblue) clcolor(edkblue) lwidth(0.5)) ///
  (line cumbilateral year, sort yaxis(2) yscale(range(0(200)900) axis(2))  ylab(0(200)884, axis(2)) mcolor(erose) clcolor(erose) lwidth(0.5)), ///
ytitle("Cumulative Number of Parties to PTAs", height(4)) ///
ytitle("Cumulative Number of PTAs", height(6) axis(2)) ///
xtitle(" ") ///
title("") ///
legend(label(2 "PTAs" ) label(3 "of which Bilateral") label(1 "Parties to at least one PTA")) ///
legend(order(2 3 1)) ///
legend(region(lstyle(none))) ///
graphregion(color(white))
graph save fig1, replace
graph export "fig1.eps", as(eps) replace


log close


